package com.heima.media.controller;


import com.heima.common.dto.ResponseResult;
import com.heima.media.dto.WmMaterialDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.heima.media.service.IWmMaterialService;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 自媒体图文素材信息表 前端控制器
 * </p>
 *
 * @author ZC
 * @since 2022-06-30
 */
@RestController
@RequestMapping("/api/v1/material")
@Api(tags = "自媒体图文素材信息表接口")
@CrossOrigin
public class WmMaterialController{

    @Autowired
    private IWmMaterialService wmMaterialService;

    @PostMapping("/upload_picture")
    @ApiOperation(value = "saveWmMaterial", notes = "图片上传")  // value =>指定名称   notes =>添加备注
    @ApiImplicitParam(name = "file", value = "MultipartFile", required = true) //required =>参数是否必填
    public ResponseResult saveWmMaterial(MultipartFile file){
        return wmMaterialService.saveWmMaterial(file);
    }
    @PostMapping("/list")
    @ApiOperation(value = "listByPage", notes = "图片列表展示")  // value =>指定名称   notes =>添加备注
    @ApiImplicitParam(name = "dto", value = "WmMaterialDto", required = true) //required =>参数是否必填
    public ResponseResult listByPage(@RequestBody WmMaterialDto dto){
        return wmMaterialService.listByPage(dto);
    }

}
